package com.tuniu.agents.impl.trip.chain;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public abstract class TripChainHandler {
    protected TripChainHandler nextHandler;
    protected String handlerName;
    

    public TripChainHandler(String handlerName) {
        this.handlerName = handlerName;
    }

    public void setNextHandler(TripChainHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public abstract String handle(String conversationId, String message);

    protected String handleNext(String conversationId, String message) {
        if (nextHandler != null) {
            return nextHandler.handle(conversationId, message);
        }
        return message;
    }

    protected void logStart() {
        log.info("{} started processing", handlerName);
    }

    protected void logEnd() {
        log.info("{} processing completed", handlerName);
    }

    protected void logError(Exception e) {
        log.error("{} processing error", handlerName, e);
    }
} 